<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1">
    <meta content=always name=referrer>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/style_user.css">
    <script src="__STATIC__/js/jquery-1.8.2.js"></script>
    <title>{eq name=":input('act')" value='edit'}修改{else/}{eq name=":input('act')" value='set'}设置{else/}忘记{/eq}{/eq}支付密码</title>
</head>
{include file="public/href" /}
<body>
<div class="wrap-pass">
    <div class="header">
        <p>{eq name=":input('act')" value='edit'}
            修改
            {else/}
            {eq name=":input('act')" value='set'}
            设置
            {else/}
            忘记
            {/eq}
            {/eq}支付密码</p>
        <!--<img src="__STATIC__/img_user/back.png" class="back" onclick="back_url()">-->
    </div>
    <form action="" method="post" id="form"  >
        <div class="center">
            <!--仅修改密码-->
            {eq name=":input('act')" value='edit'}
            <div>
                <label>原 密 码 :</label>
                <input class="text" type="password" placeholder="原密码" name="old_pwd" datatype="n6" nullmsg="旧密码不能为空" maxlength="6" errormsg="请输入6位纯数字" />
            </div>
            {/eq}
            <!--仅修改密码-->
            <div>
                <label>新 密 码 :</label>
                <input class="text" type="password" placeholder="6位新密码" name="new_pwd" datatype="n6" nullmsg="新密码不能为空" maxlength="6" errormsg="请输入6位纯数字" />
            </div>
            <div>
                <label>确认密码:</label>
                <input class="text" type="password" style="width: 74%;" placeholder="确认密码" name="confirm_new_pwd" recheck="new_pwd" datatype="*" nullmsg="确认密码不能为空" maxlength="6" errormsg="两次密码不一致" />
            </div>
        </div>
        <input type="submit" class="submit" id="yes" value="确定">
    </form>
</div>
{include file="public/src" /}
<script>
    //验证表单元素
    $(function () {
        $.Tipmsg.r = null;
        $.Tipmsg.p = null;
        $.Datatype.n6 = /^\d{6}$/;
        var demo = $("#form").Validform({
            btnSubmit:'#yes',
            tiptype: function (msg) {
                layer.open({content: msg, skin: 'msg', time:2});
            },
            tipSweep: true,
            ajaxPost:true,
            callback:function(t){
                if (t.code == 200){
//                    setTimeout(function () {
//                        layer.open({content:t.message,skin:'msg'});
//                    },2000);
                    var pay_url = sessionStorage.getItem('pay_url');
//                    console.log(pay_url);
                    if (pay_url != null){   //支付页面跳转
                        layer.open({content:t.message,skin:'msg'});
                        setTimeout(function () {
                            window.location.href = pay_url;
                        },1000);
                    }else{
                        layer.open({content:t.message,skin:'msg'});
                        setTimeout(function () {
                            window.location.href = "{:url('mobile/user_info/my_wallet')}";
                        },1000);
                    }

                }else{
                    layer.open({content:t.message,skin:'msg',time:2});
                }
            }
        });
        demo.config({
            ajaxpost:{
                error: function () {
                    layer.open({content:'网络繁忙,请重试',skin:'msg',time:2});
                }
            }
        });
    });
    //返回的路径
    function back_url(){
        if (window.location.href.indexOf('paying') >= 0){  //支付环境中
            window.location.href=sessionStorage.getItem('pay_url');
        }else{
            window.location.href="{:url('mobile/user_info/my_wallet')}";
        }
    }
</script>
</body>
</html>